<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
    <script>
        var ctx = '${ctx}';
    </script>
    <title>入库单</title>
    <meta name="decorator" content="ani"/>
    <%@ include file="/webpage/include/bootstraptable.jsp"%>
    <%@include file="/webpage/include/treeview.jsp" %>
    <script src="${ctxStatic}/common/js/common.js"></script>
    <!-- 引入 echarts.js -->
    <%@ include file="/webpage/include/echarts.jsp"%>
    <script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/echarts.min.js"></script>
    <script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts-gl/echarts-gl.min.js"></script>
    <script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts-stat/ecStat.min.js"></script>
    <script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/extension/dataTool.min.js"></script>
    <script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/map/js/china.js"></script>
    <script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/map/js/world.js"></script>
    <script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/extension/bmap.min.js"></script>
    <script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/simplex.js"></script>
    <script type="text/javascript">

        $(document).ready(function() {
            $("#inputForm").validate({
                submitHandler: function(form){
                    //jp.loading();
                    //form.submit();
                    $.ajax({
                        url:"${ctx}/transferevidence/transferEvidence/save",
                        type:"post",
                        data:$('#inputForm').serialize(),
                        beforeSend: function () {
                            // 禁用按钮防止重复提交
                            $("#submit").attr({ disabled: "disabled" });
                        },
                        success:function(data){
                            if(data.code=='0'){
                                jp.info(data.message);
                                window.location.href="${ctx}/transferevidence/transferEvidence/list";
                            }
                            else{
                                jp.warning(data.message);
                            }
                        },
                        complete: function () {
                            $("#submit").removeAttr("disabled");
                        },
                    });
                },
                errorContainer: "#messageBox",
                errorPlacement: function(error, element) {
                    $("#messageBox").text("输入有误，请先更正。");
                    if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
                        error.appendTo(element.parent().parent());
                    } else {
                        error.insertAfter(element);
                    }
                }
            });

        });
    </script>
</head>
<body>
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-md-12">
            <div class="panel panel-primary">
                <div class="panel-heading">
                    <h3 class="panel-title">
                        入库单号: ${wr.evidenceId}
                    </h3>
                </div>

                <div class="panel-body">

                        <div class="form-group">
                            <input id="conn"  type="button" class="btn btn-primary" value="闸机扫描" />
							<input id="phoneConn"  type="button" class="btn btn-primary" value="手机扫描" />
                            <input id="close" type="button" class="btn btn-success" value="识别" />
                            <input id="clear" type="button" class="btn btn-danger" value="清空" />
                            <button onclick="subResourceIds()" class="btn btn-info" data-loading-text="正在提交...">提 交</button>
                            <label id="isConnect" class="col-sm-2" style="display: none;">false</label>
                        </div>


                        <sys:message content="${message}"/>



                        <div class="form-group" >
                            <label class="col-sm-2 control-label">编码：</label>
                            <div class="col-sm-10">
                                <input id="resourceIds" name="resourceIds" path="resourceIds" htmlEscape="false" cssClass="form-control required"   class="form-control "/>
                            </div>
                        </div>



                        <div id="main" style="width: 100%;height:300px;display: none"></div>
                        <div id="resourceDiv">
                            <table id="checkResourceTable"  data-toolbar="#toolbar"></table>

                        </div>


                </div>
            </div>
        </div>

    </div>
    <table id="table"></table>
</div>
<script type="text/javascript">
    findWarehouseType("warehouseType",[]);
</script>
<script type="text/javascript">
    function subResourceIds() {

        var res=$("#resourceIds").val();
        if(res=="" || res==null){
            layer.alert('设备未启动!', {
                icon: 2,
                title: "提示"
            });
            return;
        }

        var arr=[];
        arr=$("#resourceIds").val().split(",");
        //提交数据
        var fromData=new FormData();
        //fromData.append("resourceCode","RECEIPT");
        fromData.append("ids", arr);
        fromData.append("evidenceId", ${wr.evidenceId});
        $.ajax({
            url: "${ctx}/warehouse/warehouseReceipt/passingMachine",
            type: "post",
            data: fromData,
            contentType: false, // 注意这里应设为false
            processData: false,
            beforeSend: function () {
                index = layer.load(1, {
                    shade: [0.5, '#fff'] //0.1透明度的白色背景
                });
            },
            complete: function () {
                layer.close(index);
            },
            success: function (data) {

                if (data.message == "0") {
                    layer.alert('保存成功!', {icon: 1, closeBtn: 0}, function (index) {
                        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                        parent.layer.close(index);//关闭页面
                        parent.$('#table').bootstrapTable('refresh');  //刷新table
                    });
                }else if(data.message==1){
                    layer.alert(data.data, {
                        icon: 2,
                        title: "提示"
                    });

                }
            },
            error: function (e) {
                layer.alert('保存失败!', {
                    icon: 2,
                    title: "提示"
                });

            }
        });
    }
</script>

</body>
</html>